Skip to content

Conversation

@masseyke
Copy link
Member

@masseyke masseyke commented Feb 18, 2025

Right now, TransportRolloverAction's checkBlock returns an exception if any backing index has a block. If a user puts a block on some old index, the data stream cannot rollover, even though rollover only impacts the write index (and the to-be-created write index). This changes TransportRolloverAction.checkBlock so that rollover doesn't fail if non-write-indices have a block.

@masseyke masseyke added >bug :Data Management/Data streams Data streams and their lifecycles labels Feb 18, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @masseyke, I've created a changelog YAML for you.

@masseyke masseyke added v9.0.0 v8.18.0 v8.18.1 v8.19.0 auto-backport Automatically create backport pull requests when merged labels Feb 19, 2025
@masseyke masseyke marked this pull request as ready for review February 19, 2025 17:34
@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Feb 19, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@masseyke masseyke marked this pull request as draft February 19, 2025 18:22
@masseyke masseyke marked this pull request as ready for review February 19, 2025 19:56
ResolvedExpression resolvedRolloverTarget = SelectorResolver.parseExpression(request.getRolloverTarget(), request.indicesOptions());
final IndexAbstraction indexAbstraction = state.metadata().getIndicesLookup().get(resolvedRolloverTarget.resource());
final String[] indicesToCheck;
if (indexAbstraction.getType().equals(IndexAbstraction.Type.DATA_STREAM)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we support rollover on data stream aliases? If so, would this get tripped up on one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question! But fortunately this code is in masterOperation: https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java#L238-L243:

        if (rolloverTargetAbstraction.getType() == IndexAbstraction.Type.ALIAS && rolloverTargetAbstraction.isDataStreamRelated()) {
            listener.onFailure(
                new IllegalStateException("Aliases to data streams cannot be rolled over. Please rollover the data stream itself.")
            );
            return;
        }

@masseyke masseyke requested a review from jbaiera February 20, 2025 00:00
Copy link
Member

@jbaiera jbaiera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

assertNotNull(transportRolloverAction.checkBlock(rolloverRequest, clusterState));
}
{
// Make sure checkBlock returns an exception when failure store non-write indices has a block
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Make sure checkBlock returns an exception when failure store non-write indices has a block
// Make sure checkBlock returns null when failure store non-write indices has a block

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops good catch. Also the verb is wrong in that comment. Fixing both.

@masseyke masseyke enabled auto-merge (squash) February 20, 2025 15:24
@masseyke masseyke merged commit 41dae02 into elastic:main Feb 20, 2025
16 of 17 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
9.0
8.18 Commit could not be cherrypicked due to conflicts
8.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 122905

masseyke added a commit to masseyke/elasticsearch that referenced this pull request Feb 20, 2025
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Feb 20, 2025
masseyke added a commit to masseyke/elasticsearch that referenced this pull request Feb 20, 2025
elasticsearchmachine pushed a commit that referenced this pull request Feb 20, 2025
elasticsearchmachine pushed a commit that referenced this pull request Feb 20, 2025
masseyke added a commit that referenced this pull request Feb 20, 2025
@masseyke masseyke deleted the rollover-action-checkBlock branch February 20, 2025 22:51
afoucret pushed a commit to afoucret/elasticsearch that referenced this pull request Feb 21, 2025
nielsbauman added a commit to nielsbauman/elasticsearch that referenced this pull request Mar 20, 2025
Since elastic#122905 we were throwing NPEs (i.e. 5xxs) when a rollover request
has an unknown/non-existent target. This PR restores that to it's
original behavior (which is to return a 400 - illegal argument
exception). Additionally, to avoid this from happening again, we add a
YAML test that asserts the correct exception behavior.
nielsbauman added a commit to nielsbauman/elasticsearch that referenced this pull request Mar 20, 2025
Since elastic#122905 we were throwing NPEs (i.e. 5xxs) when a rollover request
has an unknown/non-existent target. This PR restores that to it's
original behavior (which is to return a 400 - illegal argument
exception). Additionally, to avoid this from happening again, we add a
YAML test that asserts the correct exception behavior.
nielsbauman added a commit that referenced this pull request Mar 22, 2025
Since #122905 we were throwing NPEs (i.e. 5xxs) when a rollover request has an unknown/non-existent target. Before that, we returned a 400 - illegal argument exception. We now return a 404 which matches "missing target" better. Additionally, to avoid this from happening again, we add a YAML test that asserts the correct exception behavior.
nielsbauman added a commit to nielsbauman/elasticsearch that referenced this pull request Mar 22, 2025
Since elastic#122905 we were throwing NPEs (i.e. 5xxs) when a rollover request has an unknown/non-existent target. Before that, we returned a 400 - illegal argument exception. We now return a 404 which matches "missing target" better. Additionally, to avoid this from happening again, we add a YAML test that asserts the correct exception behavior.

(cherry picked from commit fdd4537)

# Conflicts:
#	server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java
nielsbauman added a commit to nielsbauman/elasticsearch that referenced this pull request Mar 22, 2025
Since elastic#122905 we were throwing NPEs (i.e. 5xxs) when a rollover request has an unknown/non-existent target. Before that, we returned a 400 - illegal argument exception. We now return a 404 which matches "missing target" better. Additionally, to avoid this from happening again, we add a YAML test that asserts the correct exception behavior.

(cherry picked from commit fdd4537)

# Conflicts:
#	server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java
elasticsearchmachine pushed a commit that referenced this pull request Mar 22, 2025
)

Since #122905 we were throwing NPEs (i.e. 5xxs) when a rollover request has an unknown/non-existent target. Before that, we returned a 400 - illegal argument exception. We now return a 404 which matches "missing target" better. Additionally, to avoid this from happening again, we add a YAML test that asserts the correct exception behavior.

(cherry picked from commit fdd4537)

# Conflicts:
#	server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java
elasticsearchmachine pushed a commit that referenced this pull request Mar 22, 2025
)

Since #122905 we were throwing NPEs (i.e. 5xxs) when a rollover request has an unknown/non-existent target. Before that, we returned a 400 - illegal argument exception. We now return a 404 which matches "missing target" better. Additionally, to avoid this from happening again, we add a YAML test that asserts the correct exception behavior.

(cherry picked from commit fdd4537)

# Conflicts:
#	server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java
elasticsearchmachine pushed a commit that referenced this pull request Mar 22, 2025
)

Since #122905 we were throwing NPEs (i.e. 5xxs) when a rollover request has an unknown/non-existent target. Before that, we returned a 400 - illegal argument exception. We now return a 404 which matches "missing target" better. Additionally, to avoid this from happening again, we add a YAML test that asserts the correct exception behavior.

(cherry picked from commit fdd4537)

# Conflicts:
#	server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java
omricohenn pushed a commit to omricohenn/elasticsearch that referenced this pull request Mar 28, 2025
Since elastic#122905 we were throwing NPEs (i.e. 5xxs) when a rollover request has an unknown/non-existent target. Before that, we returned a 400 - illegal argument exception. We now return a 404 which matches "missing target" better. Additionally, to avoid this from happening again, we add a YAML test that asserts the correct exception behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged >bug :Data Management/Data streams Data streams and their lifecycles Team:Data Management Meta label for data/management team v8.18.0 v8.18.1 v8.19.0 v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants